home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-03 / qbasicpg.zip / SHARE_EX.BAS < prev    next >
BASIC Source File  |  1988-09-17  |  745b  |  29 lines

  1. '
  2. ' *** SHARE_EX.BAS - SHARED statement programming example
  3. '
  4. DEFINT A-Z
  5. DO
  6.    INPUT "Decimal number (input number <= 0 to quit): ",Decimal
  7.    IF Decimal <= 0 THEN EXIT DO
  8.    INPUT "New base: ",Newbase
  9.    N$ = ""
  10.    PRINT Decimal "base 10 equals ";
  11.    DO WHILE Decimal > 0
  12.       CALL Convert (Decimal,Newbase)
  13.       Decimal = Decimal\Newbase
  14.    LOOP
  15.    PRINT N$ " base" Newbase
  16.    PRINT
  17. LOOP
  18.  
  19. SUB Convert (D,Nb) STATIC
  20. SHARED N$
  21.    ' Take the remainder to find the value of the current
  22.    ' digit.
  23.    R = D MOD Nb
  24.    ' If the digit is less than ten, return a digit (0...9).
  25.    ' Otherwise, return a letter (A...Z).
  26.    IF R < 10 THEN Digit$ = CHR$(R+48) ELSE Digit$ = CHR$(R+55)
  27.    N$ = RIGHT$(Digit$,1) + N$
  28. END SUB
  29.